#ifndef EPUBDUKPT_CRYPTO_BASIC_HPP
#define EPUBDUKPT_CRYPTO_BASIC_HPP

SJR_NAMESPACE_BEGIN

class EpubCryptoBasic {
public:
  class Schedule {
  public:
    Schedule() : mKeyLen(), mKey() {}

    virtual ~Schedule() = default;

    Schedule(Schedule const *) = delete;
    Schedule &operator=(Schedule const &) = delete;

    auto operator[](int idx) -> unsigned char & {
      return mKey[idx];
    }

    auto operator[](int idx) const -> unsigned char {
      return mKey[idx];
    }

    [[nodiscard]] auto data() const -> unsigned char * {
      return mKey;
    }

    [[nodiscard]] auto size() const -> int {
      return mKeyLen;
    }

  protected:
    void setKey(unsigned char *in, int inLen) {
      mKey    = in;
      mKeyLen = inLen;
    }

  private:
    int mKeyLen;
    unsigned char *mKey;
  };

  EpubCryptoBasic() = default;

  virtual ~EpubCryptoBasic() = default;

  EpubCryptoBasic(EpubCryptoBasic const &) = delete;
  EpubCryptoBasic &operator=(EpubCryptoBasic const &) = delete;

  virtual auto blockSize(Schedule *key) -> int = 0;

  virtual auto encrypt(Schedule *key, unsigned char const *in, unsigned char *out) -> bool = 0;

  virtual auto decrypt(Schedule *key, unsigned char const *in, unsigned char *out) -> bool = 0;
};

SJR_NAMESPACE_END

#endif//EPUBDUKPT_CRYPTO_BASIC_HPP
